<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script>
			function fun1(){
				//var str = document.createTextNode("这是我追加的文字");
				var ele = document.createElement("div");
				//ele.appendChild(str);
				ele.innerHTML = "文字";
				//document.body.appendChild(ele);
				con.appendChild(ele);
			}
			function fun2(){
				var ele = document.createElement("img");
				ele.setAttribute("src","img/timg.jpg");
				// ele.setAttribute("width","100px");
				ele.setAttribute("style","width: 100px;display: block;")
				con.appendChild(ele);
			}
			function fun3(){				
				con.removeChild(con.firstChild);
			}
			function fun4(){				
				con.removeChild(con.lastChild);
			}
		</script>
	</head>
	<body>
		<button onclick="fun1()">添加文本</button>
		<button onclick="fun2()">添加图片</button>
		<button onclick="fun3()">删除首个元素</button>
		<button onclick="fun4()">删除最后元素</button><br />
		<div id="con"></div>
		<script>
			var con = document.getElementById("con");
		</script>
	</body>
</html>
